<include file="public/head" />
</head>
<body>
<div class="am-modal am-modal-alert" tabindex="-1" id="fq_alert">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_alert_title"></div>
    <div class="am-modal-bd" id="fq_alert_info">
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="fq_confirm">
  <div class="am-modal-dialog">
    <div class="am-modal-hd" id="fq_confirm_title"></div>
    <div class="am-modal-bd" id="fq_confirm_info"></div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-confirm="">确定</span>
    </div>
  </div>
</div>

<link rel="stylesheet" type="text/css" href="__STATIC__/itaoke/mobile/css/allinone.css">
<link rel="stylesheet" type="text/css" href="__STATIC__/itaoke/mobile/css/grandeur.css">
<script type="text/javascript" src="__STATIC__/itaoke/mobile/js/clipboard.min.js"></script>
<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_l1c96mq0nbivygb9.css">
<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_347580_beij5hnp4f17nwmi.css">
<!-- 微信自定义接口 -->
<script>
    var content='';
    if("10"==0){
        content = document.title;
    }else{
        content =  "【在售38.28元，券后28.28元】SUV越野小车汽车方向盘套四季通用牛皮把套时尚运动汽车用品改装";
    }
    var option = {
        title:content,
        desc: "牛皮方向盘套，多色可选！手感舒适，透气防滑！装饰您的爱车很酷!",
        link: window.location.href ,
        imgUrl: "http://img01.taobaocdn.com/bao/uploaded/i1/TB19YXoPXXXXXXSXFXXXXXXXXXX_!!0-item_pic.jpg"
    };

    wx.config({"debug":false,"beta":false,"appId":"wx5d1dd00908b73f0a","nonceStr":"gnywYDCDcg","timestamp":1486361934,"url":"http:\/\/yebeihua.m.fqapps.com\/index\/details\/id\/216453537","signature":"a019cff2f970a02f3071ab71101eb9f529f90e5d","jsApiList":["onMenuShareAppMessage","onMenuShareTimeline","chooseImage","uploadImage","downloadImage","hideMenuItems"]});
    wx.ready(function(){
        wx.onMenuShareAppMessage(option);
        wx.onMenuShareTimeline(option);
    });
</script>
<!-- 微信自定义接口 -->

<style>
    body {
        color: #3d0505;
    }
    header{
        height:50px;
    }

    .am-text-truncate {
        width: 100%;
        letter-spacing: 0.4px;
    }

    .fq-free {
        line-height: 1.4;
        color: #f54d23;
    }

    .menu {
        width: 100%;
        position: fixed;
        bottom: 0;
        background: white;
        z-index: 999;
    }

        .menu img {
            width: 1.5rem;
            height: 1.5rem;
        }

        .menu ul li:nth-child(1) a {
            color: #8f8f8f;
        }

    .icon-quan2 {
        font-size: 24px;
        position: relative;
        top: 5px;
        color: #f54d23;
        line-height: 0.6;
    }

    .am-btn:hover, .am-btn:focus {
        color: white;
    }

    .fq-browser,
    .fq-browser:hover,
    .fq-browser:focus {
        width: 100%;
        height: 49px;
        background: #FB874E;
    }

    .fq-amoy,
    .fq-amoy:hover,
    .fq-amoy:focus,
    .fq-amoy:active {
        width: 100%;
        height: 49px;
        background: #f54d23;
    }

    .am-modal-no-btn .am-modal-dialog {
        border-radius: 5px;
    }

    .am-modal-hd {
        padding: 10px;
        background: #f54d23;
        border-radius: 5px 5px 0 0;
        color: white;
        font-size: 1.6rem;
    }

        .am-modal-hd .am-close {
            font-size: 36px;
            top: 8px;
            right: 8px;
            color: white;
            font-weight: 100;
            opacity: 1;
        }

    .fq-explain {
        margin-top: -28px;
        right: 16%;
        left: 16%;
    }

    .fq-goods .am-text-truncate {
        width: 100%;
    }
	
	.fq-return{
		width:36px;
		height:36px;
		position:absolute;
		top:0;
		left:0;
	}
	.fq-searchbox{
		position:absolute;
		top:0;
		right:0;
		width:36px;
		height:36px;
		background:rgba(61, 5,5, 0.4);

	}

    .fq-search {
    
    }

</style>

        <div class="fq-search am-text-center fq-background-white">
            <form action="{:C('itk_wap_url')}" class="am-form am-padding-vertical-xs am-inline-block am-text-center" id="search">
            	<input type="hidden" name="m" value="Wap">
 				<input type="hidden" name="c" value="Index">
				<input type="hidden" name="a" value="index"> 
                <input id="key" name="k" type="text" class="fq-text am-radius am-padding-vertical-xs am-text-center am-fl " style="background:#f3f3f3; border:0; width:90%;" placeholder="输入关键词搜索" value="">
                <i class="am-icon-search am-vertical-align-middle fq-text-sm am-fr" onclick="search();"></i>
            </form>
        </div>

		<a href="javascript:void(0);" onclick="back();">
				<img src="__STATIC__/itaoke/mobile/images/return.png" class="fq-return am-margin-top-sm am-margin-left-sm">
			</a>
			<div class="fq-searchbox am-inline-block am-vertical-align am-text-center fq-text-white am-round  am-margin-top-sm am-margin-right-sm">
				<i class="am-icon-search am-vertical-align-middle" style=" z-index:1"></i>
			</div>
	<script>
    function back(){
        var last_page_url = (document.referrer);
        if(last_page_url){
            window.history.back(-1);
        }else{
            window.location.href ='{:C('itk_wap_url')}';
        }
    }
    $(".fq-searchbox").click(function(){
        // $(".fq-search").slideToggle();
        if($(".fq-search").is(":hidden")){
            $(".fq-search").show();
            $(".fq-return").css("top","53px");
            $(".fq-searchbox").css("top","53px"); //如果元素为隐藏,则将它显现
        }else{
            $(".fq-search").hide();
             $(".fq-return").css("top","0");
            $(".fq-searchbox").css("top","0");    //如果元素为显现,则将其隐藏
        }
    })
</script>

<div class="fq-whole am-text-sm">
    <div class="fq-subject" style="margin-bottom:60px;">
        <div>
            <ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-gallery-default am-padding-0 am-no-layout" data-am-gallery="{ pureview: true }">
                <li class="am-padding-0">
                    <div class="am-gallery-item">
                        <a href="{$item.pic_url}" class="">
                            <img src="{$item.pic_url}" class=">" data-am-pureviewed="1">
                        </a>
                    </div>
                </li>
            </ul>
            <div class="am-padding-horizontal-xs am-padding-vertical-sm fq-background-white" style="border-bottom:1px solid #f3e7e3;">
                <strong class="am-inline-block am-text-truncate am-text-default">{$item.title}</strong>
                <strong class="am-text-sm fq-free ">券后包邮<span class="am-text-xl am-margin-left-xs" style="line-height:1.2"><neq name="share_item.coupons" value="0"><php>echo $item['coupon_price']-$item['quan'];</php></neq></span></strong>
            </div>
            <div class="am-padding-vertical-sm am-padding-horizontal-xs fq-background-white" style="border-bottom:1px solid #f3e7e3;color:#8f8f8f">
                <ul class="am-avg-sm-3 am-text-sm">
                    <li><del>在售价：{$item.coupon_price}</del></li>
                    <li class="am-text-center"><i class="icon-quan2 iconfont am-margin-right-xs"></i>{$item.quan}元</li>
                    <li class="am-text-center">销量<span class="am-margin-left-xs">{$item.volume}</span></li>
                </ul>
            </div>
            <div class="am-padding-horizontal-xs am-padding-vertical-sm fq-background-white am-text-sm">
                <strong>推荐理由</strong>
                <br>
                <div style="color:#8f8f8f;" class="am-margin-top-xs">{$item.intro}</div>
            </div>

        </div>

        <!--商品图文详情-->
        <div class="am-panel-group am-margin-vertical-sm" id="accordion">
            <div class="am-panel am-padding-horizontal-xs">
                <div class="am-panel-hd am-padding-left-0 am-padding-right-0 am-padding-vertical-sm ">
                    <h4 class="am-panel-title" data-am-collapse="{parent: '#accordion', target: '#product-details'}" data-itemid="{$item.num_iid}">
                        商品图文详情<span class="am-text-xs" style="color:#306de9">（点击展开）</span>
                        <i class="am-icon-angle-right am-fr am-icon-sm" id="change_icon"></i>
                    </h4>

                </div>
                <div id="product-details" class="am-panel-collapse am-collapse">
                    <div class="am-panel-bd am-padding-0" style="border-top: 0">
                        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
                            <div class="am-padding-top-sm" style="width:100%;overflow:auto;"></div>                        
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--商品图文详情-->
        <!--更多商品-->

        <div class="am-text-sm am-text-center am-margin-vertical-xs" style="color:#8f8f8f"><i class="am-icon-heart-o am-margin-right-xs" style="color:#f54d23"></i>猜您喜欢</div>
        <!--商品轮播-->
        <div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{&quot;directionNav&quot;:false}' style="margin-bottom: 1rem">
            <ul class="am-slides">
            <volist name="random" id="vo">
            	<if condition="$i eq 1 or $i eq 5 or $i eq 9">
                <li>
                        <ul class="am-avg-sm-4">
                </if>
                            <li class="fq-goods am-text-center">
                                 <a class="am-block" href="{:U('Item/index',array('id'=>$vo['id']))}">
                                   <img class="am-thumbnail am-margin-bottom-0 am-block" src="{$vo['pic_url']}" />
                                 </a>
                                  <a class="am-block am-text-xs am-text-truncate  fq-title">
                                    <span data-id="{$vo.num_iid}">{$vo['title']}</span>
                                  </a>
                                  <div class="am-inline-block" style="clear: both; width: 100%">
                                      <div class="am-fl fq-price am-padding-left-xs">
                                        <span class="am-text-xs am-padding-right-xs">券后</span>
                                        <php>$after_price= $vo['coupon_price']-$vo['quan']</php>
                                        <strong class="fq-text-default">{$after_price}</strong>
                                      </div>
                                   </div>
                             </li>
                   <if condition="$i eq 4 or $i eq 8 or $i eq 12">    
                        </ul>
                    </li>
                   </if>
           </volist>               
           </ul>
        </div>

        <!--更多商品-->

        <div data-am-widget="gotop" class="am-gotop am-gotop-fixed am-no-layout" style="margin-bottom:50px;">
            <a href="#top">
                <i class="am-gotop-icon am-icon-chevron-up am-round"></i>
            </a>
        </div>
        <!--底部菜单-->
        <div class="menu">
            <ul class="am-avg-sm-2">
                <li>
                    <ul class="am-avg-sm-2 am-padding-left-xs">
                        <li>
                            <a href="{:C('itk_wap_url')}" class="am-padding-vertical-sm am-block">
                                <i class="icon-shouye iconfont am-text-center am-vertical-align-middle" style="position:relative; top:2px"></i>
                                <span class=" am-text-sm am-text-center am-vertical-align-middle" style="position:relative; top:2.5px">首页</span>
                            </a>
                        </li>
                        <li>
                            <div class="am-inline-block  fq-text-sm" data-am-modal="{target:'#qrcode_large'}">
                                <a class="am-padding-vertical-sm am-block">
                                    <i class="icon-liaotiankefu iconfont  am-text-center am-vertical-align-middle" style="position:relative; top:4px;"></i>
                                    <span class=" am-text-sm am-text-center am-vertical-align-middle" style="position:relative; top:2.5px">客服</span>
                                </a>
                            </div>
                        </li>
                    </ul>
                </li>
                <li>
                    <ul class="am-avg-sm-2 am-text-center">
                        <li>
                            <button type="button" class="am-btn am-padding-horizontal-xs am-text-sm fq-browser fq-text-white">
								<a style="color:white" href="/?c=jump&a=wx&url={$item.ulandUrl}">浏览器购买</a>                            
                            </button>
                        </li>
                        <li>
                            <button type="button" class="am-btn am-padding-horizontal-xs am-text-sm fq-amoy fq-text-white" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0}">淘口令购买</button>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <!--底部菜单-->

        <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
            <div class="am-modal-dialog fq-background-white">
                <div class="am-modal-hd">
                    淘口令购买
                    <a href="javascript:void(0)" class="am-close am-close-spin" data-am-modal-close="">×</a>
                </div>
                <div class="am-modal-bd  am-padding-0">
                    <!--淘口令-->
                    <!--二合一淘口令开始-->
                        <div class="am-margin-vertical am-margin-horizontal-lg">
                            <div class="fq-goods-border am-text-center am-margin-top am-padding-vertical am-padding-horizontal-sm fq-background-white" style="margin:0;">
                                <div class="fq-explain  am-center am-text-center">
                                    <span class="am-padding-horizontal-sm fq-nowrap " style="color:white; background:#f54d23">长按框内 &gt; 全选 &gt; 复制</span>
                                </div>
                                <span id="copy_key_ios" style="display: none;">{$item.taotoken}</span>
                                <textarea style="height: 20px;" id="copy_key_android" type="text" class="am-form-field am-text-center am-text-sm " oninput="regain();">{$item.taotoken}</textarea>
                            </div>
                        </div>
                        <!--二合一淘口令结束-->
                         <div class="copy_taowords am-margin-bottom" style="display:none;">
                        <div class="share_content am-margin-bottom am-badge-success am-badge" id="share_content"></div>
                        <div class="am-text-center am-margin-top-sm ">
                            <a class="am-padding-vertical-xs am-padding-horizontal-lg am-round am-inline-block share" style="background: #f54d23; color: white;" data-taowords="{$item.taotoken}">一键复制
                            </a>
                            <div class="am-margin-top-sm am-text-xs am-text-primary am-margin-horizontal-sm">点击复制后，请打开【手机淘宝】购买！</div>
                        </div>
                    </div>
                    <div class="am-text-left am-text-xs am-padding-vertical-sm am-padding-horizontal-lg" style="background:#f3f3f3; border-radius:0 0 5px 5px;color:#86564B">
                        <span>
						<span>使用说明：</span>
                            <span>复制淘口令后打开【手机淘宝】即可领取优惠券购买！</span>
                        </span><br><span><span>温馨提示：</span> 手机无【手机淘宝】者，可选择浏览器购买方式哦~</span>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-modal am-modal-no-btn" tabindex="-1" id="qrcode_large">
            <div class="am-modal-dialog">
                <div class="am-modal-hd">
                    <span class="am-text-sm">点击二维码放大后长按关注</span>
                    <a href="javascript: void(0)" class="am-close" data-am-modal-close="">×</a>
                </div>
					<ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-gallery-default am-no-layout" data-am-gallery="{pureview: 1}">
						<li>
							<div class="am-gallery-item">
                              <img src="{:C('itk_site_wxkefu')}" alt="" data-am-pureviewed="1">
								<span class="am-text-xs am-text-danger" style="top: -2px;position: relative;">客服微信</span>  
							</div>
						</li>
					</ul>
                </div>
            </div>
        </div>
    </div>
    
     <!--图文详情合成-->
<button type="button" class="fq-camera am-round am-padding-horizontal-0">
  <i class="iconfont icon-camera"></i>
</button>

<div class="fq-sharecanvas" style="display:none">  
   <div class="fq-canvas">
        <i class="am-icon-close am-round"></i>
    <canvas id="sharecanvas" style="background-color:white;display:none; width:80%" class="am-text-center am-center"></canvas>
    <img src="" class="imgData"/>
     <div class="fq-canvas-explain am-text-sm fq-text-white am-margin-top-sm am-padding-xs">
      <span class="image_loading" style="display:none;"><i class="am-icon-spinner am-icon-pulse am-margin-right-xs"></i>图文合成中，请耐心稍等片刻</span>
       <span class="image_show">  说明：长按上方图片即可发送图片或保存图片。</span>
     </div>  
    </div>
</div>
<script>
    $(function () {
        //事件监听
        //------------------------------------------
        var ua = navigator.userAgent.toLowerCase();
        if (ua.match(/iphone os 11/i) == "iphone os 11") {
            $('.copy_taowords').show();
            
            var clipboard = new Clipboard('.share', {
                target: function() {
                    return document.querySelector('.share_content');
                }
            });

            clipboard.on('success', function(e){
                e.trigger.innerHTML="已复制";
                e.trigger.style.backgroundColor="#9ED29E";
                e.trigger.style.borderColor="#9ED29E";
                $(".share_content").hide();
                console.info('Action:', e.action);
                console.info('Text:', e.text);
                console.info('Trigger:', e.trigger);
                e.clearSelection();
            });

            clipboard.on('error', function(e) {
                $(".share_content").hide();
                $("#fq_alert_info").html("<div class=\"am-text-danger\">由于您的浏览器不兼容或当前网速较慢，复制失败，请手动复制或更换主流浏览器！</div><div class=\"am-margin\" style=\"text-align: left;\">"+$(".share_content").html()+"</div>");
                $('#fq_alert').modal();
            });
        }     
            document.addEventListener("selectionchange", function (e) {
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios' && document.getElementById('copy_key_ios').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios1' && document.getElementById('copy_key_ios1').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios1');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios2' && document.getElementById('copy_key_ios2').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios2');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios3' && document.getElementById('copy_key_ios3').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios3');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios4' && document.getElementById('copy_key_ios4').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios4');
                    window.getSelection().selectAllChildren(key);
                }
            }, false);
    });

                 document.addEventListener("selectionchange", function (e) {
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios' && document.getElementById('copy_key_ios').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios1' && document.getElementById('copy_key_ios1').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios1');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios2' && document.getElementById('copy_key_ios2').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios2');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios3' && document.getElementById('copy_key_ios3').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios3');
                    window.getSelection().selectAllChildren(key);
                }
                if (window.getSelection().anchorNode.parentNode.id == 'copy_key_ios4' && document.getElementById('copy_key_ios4').innerText != window.getSelection()) {
                    var key = document.getElementById('copy_key_ios4');
                    window.getSelection().selectAllChildren(key);
                }
            }, false);

    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
        $('.fq-explain span').html("长按框内 > 拷贝");

    } else {
        $("#copy_key_ios").hide();
        $("#copy_key_ios1").hide();
        $("#copy_key_ios2").hide();
        $("#copy_key_ios3").hide();
        $("#copy_key_ios4").hide();
        $("#copy_key_android").show();
        $("#copy_key_android1").show();
        $("#copy_key_android2").show();
        $("#copy_key_android3").show();
        $("#copy_key_android4").show();
    }

    $(".share").on('click', function() {
        var taowords = $(this).attr('data-taowords');
        console.log(taowords);
        $('.share_content').html(taowords);
    })

    //获取宝贝详情
    $('.am-panel-title').click(function () {
        //详情显影
        if ($("#product-details").is(":hidden")) {
            $("#change_icon").removeClass('am-icon-angle-right').addClass('am-icon-angle-down');
            $('.am-tab-panel').html('<span class="am-center am-text-center am-margin-vertical-xs">图片努力加载中<i class="am-icon-spinner am-icon-pulse am-margin-left-xs"></i></span>');
        } else {
            $("#change_icon").removeClass('am-icon-angle-down').addClass('am-icon-angle-right');
        }
        var itemid = $(this).attr('data-itemid');
        getiteminfo(itemid);
    });

    //采集宝贝详情的图片内容
    function getiteminfo(itemid) {
        $.ajax({
            url: "https://hws.m.taobao.com/cache/mtop.wdetail.getItemDescx/4.1/?data=%7Bitem_num_id%3A" + itemid + "%7D&type=jsonp&dataType=jsonp",
            dataType: 'jsonp',
            jsonp: 'callback',
            success: function (result) {
                if (result.ret[0] == "SUCCESS::接口调用成功") {
                    var len = result.data.images.length;
                    var image = new Array();
                    for (var i = 0; i < len; i++) {
                        image[i] = '<img src="' + result.data.images[i] + '">';
                    }
                    $('.am-tab-panel').html(image);
                } else {
                    $("#qf_alert_info").html("宝贝数据调用失败，原因：" + result.ret[0]);
                    $('#qf_alert').modal();
                }
            }
        });
    }
</script>
<script>
    if(document.getElementById("copy_key_android")){
        var taokouling_value = document.getElementById("copy_key_android").value;
        function regain() {
            document.getElementById('copy_key_android').value = taokouling_value;
        }
    }
    if(document.getElementById("copy_key_android1")){
        var taokouling_value1 = document.getElementById("copy_key_android1").value;
        function regain1() {
            document.getElementById('copy_key_android1').value = taokouling_value1;
        }
    }
    if(document.getElementById("copy_key_android2")){
        var taokouling_value2 = document.getElementById("copy_key_android2").value;
        function regain2() {
            document.getElementById('copy_key_android2').value = taokouling_value2;
        }
    }
    if(document.getElementById("copy_key_android3")){
        var taokouling_value3 = document.getElementById("copy_key_android3").value;
        function regain3() {
            document.getElementById('copy_key_android3').value = taokouling_value3;
        }
    }
    if(document.getElementById("copy_key_android4")){
        var taokouling_value4 = document.getElementById("copy_key_android4").value;
        function regain4() {
            document.getElementById('copy_key_android4').value = taokouling_value4;
        }
    }
</script>
<script>
    function post(URL, PARAMS) {
        var temp = document.createElement("form");
        temp.action = URL;
        temp.method = "post";
        temp.style.display = "none";
        for (var x in PARAMS) {
            var opt = document.createElement("textarea");
            opt.name = x;
            opt.value = PARAMS[x];
            temp.appendChild(opt);
        }
        document.body.appendChild(temp);
        temp.submit();
        return temp;
    }
    $(function(){
        $('.share_btn').on('click', function() {
         //   post('/index/details'+'/id/'+$(this).data('id'), {share:true});
        });
    });

    function search(){
        $("#search").submit();
    }
    var camera = 1;
        // 新增海报推广
 $(".fq-camera").click(function(){
    if(camera == 1) {
        if($('.imgData').attr('src')==""){
            $('.image_loading').show();
            $('.image_show').hide();
        }
        canvasApp();
        $(".fq-sharecanvas").css("display","flex");
    } else {
        $('#fq_alert_info').text('您当前IOS版本暂不支持该功能，请升级到IOS9.3以上。');
        $('#fq_alert').modal();
    }
});

$(".fq-canvas .am-icon-close").click(function(){
     $(".fq-sharecanvas").css("display","none");
});
	
        function canvasApp() {
                var is_agent = window.localStorage.getItem('is_agent') || 0;
                var p_id = window.localStorage.getItem('adzone_pid') || '';
                var id = "1782522";
                var push_type = "";
                var item_src= window.location.href;
                var canvas = document.getElementById('sharecanvas');

                var ctx = canvas.getContext('2d');
                ctx.fillStyle = "#fff";  
                canvas.width = (document.documentElement.clientWidth * 0.9) * 2;
                canvas.height = canvas.width / 2 + 680;

                var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
                for(var i = 0; i < imageData.data.length; i += 4) {
                    // 当该像素是透明的，则设置成白色
                if(imageData.data[i + 3] == 0) {
                    imageData.data[i] = 255;
                    imageData.data[i + 1] = 255;
                    imageData.data[i + 2] = 255;
                    imageData.data[i + 3] = 255; 
                    }
                }
                ctx.putImageData(imageData, 0, 0);

                /*商品主图*/
                var item_img = new Image()
                item_img.setAttribute('crossOrigin','anonymous');
                item_img.src =  'http://api.fqapps.com/bridge/image?url='+ encodeURIComponent('{$item.pic_url}');
        //        item_img.src =  '{$item.pic_url}';
                item_img.onload = function() {
                ctx.drawImage(item_img, 0, 0, canvas.width, canvas.width);

                /*二维码*/
                var code_img = new Image()
                code_img.setAttribute('crossOrigin','anonymous');
                code_img.src =  'http://api.fqapps.com/bridge/image?url='+ encodeURIComponent('http://www.52codes.net/qr/api.php?p=3.2&url='+window.location.href);
                
                code_img.onload = function() {
                ctx.drawImage(code_img, canvas.width - 220,canvas.width + 20,200, 200);

                /*商品标题*/
                var str = '{$item.title}';
                ctx.fillStyle='#605761';
                ctx.lineWidth=1; 
                ctx.textAlign = 'left';
                ctx.textBaseline = "top";
                ctx.font = '28px Helvetica';
                var lineWidth = 0;
                var canvasWidth = canvas.width - 60;//计算canvas的宽度
                var initHeight= canvas.width + 30;//绘制字体距离canvas顶部初始的高度
                var lastSubStrIndex= 0; //每次开始截取的字符串的索引
                for(var i = 0;i <= str.length; i++){ 
                    lineWidth += ctx.measureText(str[i]).width; 
                    if(lineWidth > canvasWidth - 230){ 
                        ctx.fillText(str.substring(lastSubStrIndex,i),20,initHeight);//绘制截取部分
                        initHeight += 40;//字体的高度
                        lineWidth = 0;
                        lastSubStrIndex = i;
                    } 
                    if(i == str.length - 1 ){
                        ctx.fillText(str.substring(lastSubStrIndex,i + 1 ),20,initHeight);
                    }
                    }
                
                /*原价*/
                 var price = '在售价：{$item['coupon_price']}';
                ctx.fillStyle = '#aba0ac';
                ctx.textAlign = 'left';
                ctx.font = '30px Helvetica';
                ctx.textBaseline = "top";
                ctx.fillText(price,20,initHeight + 30);

                /*删除线*/
                ctx.strokeStyle = '#aba0ac';
                ctx.lineWidth = 2; // 改变线的粗细 
                ctx.moveTo(20, initHeight + 46); // 起始点 
                ctx.lineTo(200, initHeight + 46); // 第二点(如果是一条直线的话，就是终点) 
                ctx.stroke();

                /*在售标题*/
                var end_price_title = '下单价:';
                ctx.fillStyle = '#aba0ac';
                ctx.textAlign = 'left';
                ctx.font = '30px Helvetica';
                ctx.textBaseline = "top";
                ctx.fillText(end_price_title,20,initHeight + 80);

                /*在售价格*/
                var end_price = '{$after}';
                ctx.fillStyle = '#fba137';
                ctx.textAlign = 'left';
                ctx.font = '42px Helvetica';
                ctx.textBaseline = "top";
                ctx.fillText(end_price,140,initHeight + 72);
		
                 /*优惠券金额*/
                  var end_price = '券{$item['quan']}元';
                  ctx.fillStyle = '#fba137';
                  ctx.textAlign = 'left';
                  ctx.font = '30px Helvetica';
                  ctx.textBaseline = "top";
                  ctx.fillText(end_price,220,initHeight + 30);
                  
                /*虚线*/
                ctx.setLineDash([10,5]); 
                ctx.lineWidth = 1; 
                ctx.strokeStyle = '#aba0ac'; 
                ctx.beginPath(); 
                ctx.moveTo(10, canvas.height - 50); 
                ctx.lineTo(canvas.width - 10, canvas.height - 50 ); 
                ctx.stroke(); 

                /*矩形遮罩*/
                ctx.fillStyle = 'white'
                ctx.lineWidth = 0;
                ctx.beginPath();
                ctx.moveTo((canvas.width - 308) / 2 - 10,canvas.height - 64 );
                ctx.lineTo((canvas.width - 308) / 2 + 320,canvas.height - 64 );
                ctx.lineTo((canvas.width - 308) / 2 + 320,canvas.height - 46 );
                ctx.lineTo((canvas.width - 308) / 2 - 10,canvas.height - 46 );
                ctx.lineTo((canvas.width - 308) / 2 - 10,canvas.height - 64 );
                ctx.fill();

                /*提示文字*/
                var code_title = '长按二维码识别查看商品';
                ctx.fillStyle = '#aba0ac';
                ctx.font = '28px Helvetica';
                ctx.fillText(code_title,(canvas.width - 308) / 2,canvas.height - 64 );

                /*保存为图片*/
                var image = new Image();
                image.setAttribute('crossOrigin','anonymous');
                image.src = canvas.toDataURL("img/png");
                $(".imgData").attr("background","white");
                $(".imgData").attr("src",image.src);

                if($('.imgData').attr('src')!=""){
                    $('.image_loading').hide();
                    $('.image_show').show();
                }
            }
          }

        } 
</script>
<div class="am-hide"></div>
</html>